package com.wms.controller.open;


import com.wms.controller.admin.BaseController;
import com.wms.entity.Resource;
import com.wms.service.ResourceService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import javax.servlet.http.HttpServletRequest;


@RequestMapping("/open/resource")
@RestController("openResourceController")
public class ResourceController extends BaseController {

    @Autowired
    private ResourceService resourceService;


    @RequestMapping("/menu")
    public Object menu(HttpServletRequest request){
        String username = (String) request.getAttribute("username");
        if (StringUtils.isEmpty(username)){
            return unauthorize();
        }

        List<Resource> list = resourceService.getMenuByUsername(username);
        return success(list);
    }




}
